package Offer.offer2017;

import domain.ListNode;

/**
 * 反转链表
 * Created by 雷文康 on 2017/12/31.
 */
public class Test16 {
    public static ListNode reverseList(ListNode head){
        if(head == null){
            return null;
        }
        ListNode p = head;
        ListNode next = p.next;
        while (p.next != null){
            ListNode nextNext = next.next;
            next.next = p;
            p = next;
            next = nextNext;
        }
        return p;
    }
}
